//本地部署
const express = require( 'express')
const history = require('connect-history-api-fallback')
const { createProxyMiddleware } = require('http-proxy-middleware')

//端口
const PORT = 5001

const app = express()

app.use(history())
app.use(express.static(__dirname + '/public'))
app.use(
  '/api',
  createProxyMiddleware({
    //服务器地址
    target: 'http://172.31.61.111:5000',
    changeOrigin: true,
    pathRewrite: {'^/api' : ''}
  }),
);

app.listen(PORT,() => {
  console.log(`服务器启动,端口号：${PORT}`)
})